package cn.tedu.smartos.health.controller;

import cn.tedu.smartos.base.response.JsonResult;
import cn.tedu.smartos.health.pojo.dto.HealthAddParam;
import cn.tedu.smartos.health.pojo.vo.HealthDataVO;
import cn.tedu.smartos.health.service.HealthService;
import com.github.pagehelper.PageInfo;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "06.健康模块")
@Slf4j
@RestController
@RequestMapping("/api/v1/health/")
public class HealthController {
    @Autowired
    private HealthService healthService;

    @ApiOperation("采集数据")
    @ApiOperationSupport(order = 10)
    @PostMapping("add")
    public JsonResult add(HealthAddParam healthAddParam) {
        log.debug("开始处理【添加健康数据】的请求，参数：{}", healthAddParam);
        healthService.add(healthAddParam);
        return JsonResult.ok();
    }
    @ApiOperation("查询原始数据")
    @ApiOperationSupport(order = 20)
    @GetMapping("list")
    public JsonResult list(@RequestParam(defaultValue = "1") Integer pageNum,
                           @RequestParam(defaultValue = "10") Integer pageSize,
                           @RequestParam(required = false) Long elderlyUserId) {
        log.debug("开始处理【查询原始数据】的请求,{},{}",pageNum,pageSize,elderlyUserId);
        PageInfo<HealthDataVO> list = healthService.list(pageNum,pageSize,elderlyUserId);
        return JsonResult.ok(list);
    }
    @ApiOperation("数据分析")
    @ApiOperationSupport(order = 30)
    @GetMapping("analysis")
    public JsonResult analysis(){
        log.debug("开始处理【数据分析】的请求");
        return JsonResult.ok();
    }
}
